From d3284cf35b8d92029cba487a285cdd6aeee16d38 Mon Sep 17 00:00:00 2001
From: Joerg Riesmeier <dicom@offis.de>
Date: Tue, 1 Feb 2011 09:52:35 +0000
Subject: [PATCH 6/6] Added optional support for building shared libraries with CMake.

---
 CMakeLists.txt               |    2 ++
 dcmimage/apps/CMakeLists.txt |    3 +--
 dcmimgle/apps/CMakeLists.txt |    3 +--
 dcmjpeg/apps/CMakeLists.txt  |    5 ++---
 dcmjpls/apps/CMakeLists.txt  |    3 +--
 dcmpstat/apps/CMakeLists.txt |    8 +-------
 dcmqrdb/apps/CMakeLists.txt  |    4 ++--
 dcmwlm/apps/CMakeLists.txt   |    4 ++--
 8 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa5d9ad..010c13c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,8 @@ SET(DCMTK_API_VERSION "${DCMTK_MAJOR_VERSION}.${DCMTK_MINOR_VERSION}")
 SET(DCMTK_LIBRARY_PROPERTIES VERSION "${DCMTK_PACKAGE_VERSION}" SOVERSION "${DCMTK_API_VERSION}")
 SET(DCMTK_PACKAGE_VERSION_NUMBER ${DCMTK_MAJOR_VERSION}${DCMTK_MINOR_VERSION}${DCMTK_BUILD_VERSION})
 
+# General build options
+OPTION(BUILD_SHARED_LIBS "Build with shared libraries." OFF)
 
 # DCMTK build options
 OPTION(DCMTK_WITH_CHARLS "Configure DCMTK with support for CHARLS" ON)
diff --git a/dcmimage/apps/CMakeLists.txt b/dcmimage/apps/CMakeLists.txt
index aad94cf..d3f241f 100644
--- a/dcmimage/apps/CMakeLists.txt
+++ b/dcmimage/apps/CMakeLists.txt
@@ -13,6 +13,5 @@ ENDFOREACH(PROGRAM)
 
 # make sure executables are linked to the corresponding libraries
 FOREACH(PROGRAM dcm2pnm dcmquant dcmscale)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmimage dcmimgle dcmdata oflog ofstd ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
+  TARGET_LINK_LIBRARIES(${PROGRAM} dcmimage dcmimgle dcmdata oflog ofstd ${LIBTIFF_LIBS} ${LIBPNG_LIBS} ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
 ENDFOREACH(PROGRAM)
-TARGET_LINK_LIBRARIES(dcm2pnm ${LIBTIFF_LIBS} ${LIBPNG_LIBS})
diff --git a/dcmimgle/apps/CMakeLists.txt b/dcmimgle/apps/CMakeLists.txt
index 8514a47..440b321 100644
--- a/dcmimgle/apps/CMakeLists.txt
+++ b/dcmimgle/apps/CMakeLists.txt
@@ -13,6 +13,5 @@ ENDFOREACH(PROGRAM)
 
 # make sure executables are linked to the corresponding libraries
 FOREACH(PROGRAM dcmdspfn dcod2lum dconvlum)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmimgle oflog ofstd ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
+  TARGET_LINK_LIBRARIES(${PROGRAM} dcmimgle dcmdata oflog ofstd ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
 ENDFOREACH(PROGRAM)
-TARGET_LINK_LIBRARIES(dcmdspfn dcmdata)
diff --git a/dcmjpeg/apps/CMakeLists.txt b/dcmjpeg/apps/CMakeLists.txt
index 9c1f565..b9bc30b 100644
--- a/dcmjpeg/apps/CMakeLists.txt
+++ b/dcmjpeg/apps/CMakeLists.txt
@@ -2,7 +2,7 @@
 INCLUDE_DIRECTORIES(${dcmjpeg_SOURCE_DIR}/include ${ofstd_SOURCE_DIR}/include ${oflog_SOURCE_DIR}/include ${dcmdata_SOURCE_DIR}/include ${dcmimgle_SOURCE_DIR}/include ${dcmimage_SOURCE_DIR}/include ${dcmjpeg_SOURCE_DIR}/libijg8 ${dcmjpeg_SOURCE_DIR}/libijg12 ${dcmjpeg_SOURCE_DIR}/libijg16 ${ZLIB_INCDIR} ${LIBTIFF_INCDIR} ${LIBPNG_INCDIR})
 
 # declare directories containing used libraries
-LINK_DIRECTORIES(${dcmjpeg_BINARY_DIR} ${ofstd_BINARY_DIR} ${oflog_BINARY_DIR} ${dcmdata_BINARY_DIR} ${dcmimgle_BINARY_DIR} ${dcmimage_BINARY_DIR}  ${ZLIB_LIBDIR} ${LIBTIFF_LIBDIR} ${LIBPNG_LIBDIR})
+LINK_DIRECTORIES(${dcmjpeg_BINARY_DIR} ${ofstd_BINARY_DIR} ${oflog_BINARY_DIR} ${dcmdata_BINARY_DIR} ${dcmimgle_BINARY_DIR} ${dcmimage_BINARY_DIR} ${ZLIB_LIBDIR} ${LIBTIFF_LIBDIR} ${LIBPNG_LIBDIR})
 
 # declare executables
 FOREACH(PROGRAM dcmcjpeg dcmdjpeg dcmj2pnm dcmmkdir)
@@ -16,6 +16,5 @@ ENDFOREACH(PROGRAM)
 
 # make sure executables are linked to the corresponding libraries
 FOREACH(PROGRAM dcmcjpeg dcmdjpeg dcmj2pnm dcmmkdir)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmjpeg ijg8 ijg12 ijg16 dcmimage dcmimgle dcmdata oflog ofstd ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
+  TARGET_LINK_LIBRARIES(${PROGRAM} dcmjpeg ijg8 ijg12 ijg16 dcmimage dcmimgle dcmdata oflog ofstd ${LIBTIFF_LIBS} ${LIBPNG_LIBS} ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
 ENDFOREACH(PROGRAM)
-TARGET_LINK_LIBRARIES(dcmj2pnm ${LIBTIFF_LIBS} ${LIBPNG_LIBS})
diff --git a/dcmjpls/apps/CMakeLists.txt b/dcmjpls/apps/CMakeLists.txt
index 45abcb9..41fc329 100644
--- a/dcmjpls/apps/CMakeLists.txt
+++ b/dcmjpls/apps/CMakeLists.txt
@@ -16,6 +16,5 @@ ENDFOREACH(PROGRAM)
 
 # make sure executables are linked to the corresponding libraries
 FOREACH(PROGRAM dcmcjpls dcmdjpls dcml2pnm)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmjpls ${CHARLS_LIBS} dcmimage dcmimgle dcmdata oflog ofstd ofstd ${ZLIB_LIBS} ${THREAD_LIBS} ${WIN32_STD_LIBRARIES})
+  TARGET_LINK_LIBRARIES(${PROGRAM} dcmjpls ${CHARLS_LIBS} dcmimage dcmimgle dcmdata oflog ofstd ofstd ${LIBTIFF_LIBS} ${LIBPNG_LIBS} ${ZLIB_LIBS} ${THREAD_LIBS} ${WIN32_STD_LIBRARIES})
 ENDFOREACH(PROGRAM)
-TARGET_LINK_LIBRARIES(dcml2pnm ${LIBTIFF_LIBS} ${LIBPNG_LIBS})
diff --git a/dcmpstat/apps/CMakeLists.txt b/dcmpstat/apps/CMakeLists.txt
index e795197..48398a8 100644
--- a/dcmpstat/apps/CMakeLists.txt
+++ b/dcmpstat/apps/CMakeLists.txt
@@ -17,11 +17,5 @@ ENDFOREACH(PROGRAM)
 
 # make sure executables are linked to the corresponding libraries
 FOREACH(PROGRAM dcmmkcrv dcmmklut dcmp2pgm dcmprscp dcmprscu dcmpsmk dcmpschk dcmpsprt dcmpsrcv dcmpssnd)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmpstat dcmimgle dcmqrdb dcmnet dcmdata oflog ofstd ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
-ENDFOREACH(PROGRAM)
-FOREACH(PROGRAM dcmmklut dcmp2pgm dcmprscp dcmprscu dcmpschk dcmpsmk dcmpsprt dcmpsrcv dcmpssnd)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmsr)
-ENDFOREACH(PROGRAM)
-FOREACH(PROGRAM dcmp2pgm dcmprscp dcmprscu dcmpsprt dcmpsrcv dcmpssnd)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmtls dcmdsig ${LIBXML_LIBS} ${OPENSSL_LIBS})
+  TARGET_LINK_LIBRARIES(${PROGRAM} dcmpstat dcmdsig dcmsr dcmimgle dcmqrdb dcmnet dcmtls dcmdata oflog ofstd ${LIBXML_LIBS} ${OPENSSL_LIBS} ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
 ENDFOREACH(PROGRAM)
diff --git a/dcmqrdb/apps/CMakeLists.txt b/dcmqrdb/apps/CMakeLists.txt
index 249732c..6be0507 100644
--- a/dcmqrdb/apps/CMakeLists.txt
+++ b/dcmqrdb/apps/CMakeLists.txt
@@ -1,5 +1,5 @@
 # declare directories containing used libraries
-LINK_DIRECTORIES(${dcmqrdb_BINARY_DIR} ${ofstd_BINARY_DIR} ${oflog_BINARY_DIR} ${dcmdata_BINARY_DIR} ${dcmnet_BINARY_DIR} ${ZLIB_LIBDIR})
+LINK_DIRECTORIES(${dcmqrdb_BINARY_DIR} ${ofstd_BINARY_DIR} ${oflog_BINARY_DIR} ${dcmdata_BINARY_DIR} ${dcmnet_BINARY_DIR} ${ZLIB_LIBDIR} ${OPENSSL_LIBDIR})
 
 # declare executables
 FOREACH(PROGRAM dcmqrscp dcmqridx dcmqrti)
@@ -13,5 +13,5 @@ ENDFOREACH(PROGRAM)
 
 # make sure executables are linked to the corresponding libraries
 FOREACH(PROGRAM dcmqrscp dcmqridx dcmqrti)
-  TARGET_LINK_LIBRARIES(${PROGRAM} dcmqrdb dcmnet dcmdata oflog ofstd ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
+  TARGET_LINK_LIBRARIES(${PROGRAM} dcmqrdb dcmnet dcmdata oflog ofstd ${OPENSSL_LIBS} ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
 ENDFOREACH(PROGRAM)
diff --git a/dcmwlm/apps/CMakeLists.txt b/dcmwlm/apps/CMakeLists.txt
index 445881f..13865ca 100644
--- a/dcmwlm/apps/CMakeLists.txt
+++ b/dcmwlm/apps/CMakeLists.txt
@@ -2,7 +2,7 @@
 INCLUDE_DIRECTORIES(${dcmtls_SOURCE_DIR}/include)
 
 # declare directories containing used libraries
-LINK_DIRECTORIES(${dcmwlm_BINARY_DIR} ${ofstd_BINARY_DIR} ${oflog_BINARY_DIR} ${dcmdata_BINARY_DIR} ${dcmtls_BINARY_DIR} ${dcmnet_BINARY_DIR} ${ZLIB_LIBDIR})
+LINK_DIRECTORIES(${dcmwlm_BINARY_DIR} ${ofstd_BINARY_DIR} ${oflog_BINARY_DIR} ${dcmdata_BINARY_DIR} ${dcmtls_BINARY_DIR} ${dcmnet_BINARY_DIR} ${ZLIB_LIBDIR} ${OPENSSL_LIBDIR})
 
 # declare executables
 ADD_EXECUTABLE(wlmscpfs wlmscpfs wlcefs)
@@ -11,4 +11,4 @@ ADD_EXECUTABLE(wlmscpfs wlmscpfs wlcefs)
 INSTALL_TARGETS(${INSTALL_BINDIR} wlmscpfs)
 
 # make sure executables are linked to the corresponding libraries
-TARGET_LINK_LIBRARIES(wlmscpfs dcmwlm dcmnet dcmtls dcmdata oflog ofstd ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
+TARGET_LINK_LIBRARIES(wlmscpfs dcmwlm dcmnet dcmtls dcmdata oflog ofstd ${OPENSSL_LIBS} ${ZLIB_LIBS} ${WIN32_STD_LIBRARIES} ${THREAD_LIBS})
-- 
1.7.4

